import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { getListData } from "./actions";
const Child = () => {
    const { loading, list, page } = useSelector(state => state)
    const dispatch = useDispatch()
    useEffect(() => {
        dispatch(getListData);
    }, [page, dispatch])
    return (
        <div>
            <h2>Cnode查询列表显示</h2>
            {
                loading ? <p>数据获取中</p> : <ul>
                    {list.map(item => <li key={item.id}>{item.title}</li>)}
                </ul>
            }
            <button onClick={() => { dispatch({ type: "perv" }) }}>上一页</button>
            <button onClick={() => { dispatch({ type: "next" }) }}>下一页</button>
        </div>
    )
}
export default Child